import redis.clients.jedis.Jedis;
import utils.RedisUtils;

import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.locks.Lock;

/**
 * java 整合 Redis 并使用
 */
public class JavaAndRedis {
    public static void main(String[] args) {
        Jedis jedis = RedisUtils.redisConnect("127.0.0.1",6379);
        System.out.println("连接成功");
        jedis.set("runoobkey1", "www.runoob.com1");
        jedis.set("runoobkey2", "www.runoob.com2");
        jedis.set("runoobkey3", "www.runoob.com3");
        jedis.set("runoobkey4", "www.runoob.com4");
        Set<String> keys = jedis.keys("*");
        Iterator<String> i = keys.iterator();
        while (i.hasNext()){
            String key = i.next();
            System.out.println(jedis.get(key));
            System.out.println(key);
        }
        jedis.del("userlist");
        System.out.println(jedis.get("runoobkey"));


    }



}
